﻿using System;
namespace Colors.Xroad.Eu.Messages {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="CanMixResponse", Namespace="http://colors.x-road.eu/", Target=typeof(CanMixResponse))]
    public class CanMixResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected CanMixResponse clazz;
        
        public CanMixResponseSerializer(CanMixResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("response");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.Response))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="response") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>CanMixResponse>response");
                }
                clazz.Response = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("response")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>CanMixResponse>response", Reader.LocalName);
            }
        }
    }
}
